import java.util.Scanner;
import java.util.Stack;

public class Test {
    public static void main(String[] args) {
        System.out.println(T.单手撕递归(5));
        String str = "11";
        System.out.println("".equals(str));
    }
}
class T{
    /**
     * 功能：传入任意n我就能求出他的阶乘值
     *
     * @param n
     * @return
     */
    public static int 单手撕递归(int n){
        //1.递归终止条件
        if (n == 1){
            return n;
        }
        //2.不需要借助任何方法，就可以解除当前问题，当前问题就是求n自身
        //3.剩下的(n-1)的阶乘问题，交给  单手撕递归(int n)  这个方法

        //我当前只知道n的值，剩下的值n-1我不知道，交给别人去处理
        //调用单手撕递归，能帮我求出n-1的阶乘值
        //最后我只需要拼接答案即可
        return n * 单手撕递归(n-1);
    }




    public static void showTab(int n ){
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= i; j++) {
                System.out.print(j+"*"+i+"="+i*j+"  ");
            }
            System.out.println();
        }
    }
    private static void showElement(int num){
        Stack stack = new Stack();
        while (num != 0){
            stack.push(num % 10);
            num = num / 10;
        }
        while (stack.peek() != null){
            System.out.println(stack.pop());
            if (stack.size() == 0){
                break;
            }
        }
    }
    public static void onLoad(int count){
        String password = "123";
        System.out.println("输入密码:");
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        if (count < 3){
            if (s.equals(password)){
                System.out.println("登录成功");
            }else {
                count++;
                System.out.println("密码不正确，你还有"+(3-count)+"次机会，请重新输入：");
                if (count < 3){
                    onLoad(count);
                }
            }
        }
    }
    private static void maxCommondivisor(int num1,int num2){
        int min = Math.min(num1,num2);
        for (int i = (min/2); i > 0; i--) {
            if (num1 % i == 0 && num2 % i == 0){
                System.out.println(i);
                return;
            }
        }
    }
    public static void calculate(){
        double sum = 1;
        for (int i = 2; i <= 100; i++) {
            if (i % 2 == 1){
                sum = sum + (1.0/i);
            }else {
                sum = sum -  (1.0 / i);
            }
        }
        System.out.println(sum);
    }
    public static void isRight(){
        for (int i = 100; i < 999; i++) {
            int a = i / 100;
            int b = (i / 10) % 10;
            int c = i % 10;
            if (Math.pow(a,3) + Math.pow(b,3) + Math.pow(c,3) == i){
                System.out.println(i);
            }
        }
    }
    public static int  nineCount(){
        int count = 0;
        int i = 1;
        while (i < 100){
            if (i % 10 == 9){
                count ++;
            }
            if (i / 10 == 9){
                count++;
            }
            i++;
        }
        return count;
    }
    public static void ruiYears(){
        int i = 1000;
        while (i <= 2000){
            if (i % 4 != 0){
                i++;
                continue;
            }else {
                System.out.print(i+"年 ");
            }
            if (i % 80 == 0){
                System.out.println();
            }
            i++;
        }
    }
    public static void printSushu(){

        for (int i = 1; i < 4; i++) {
            System.out.println(i);
        }
        for (int i = 1; i < 100; i += 2) {
            for (int j = 2; j < Math.sqrt(i); j++) {
                if (i % j == 0){
                    break;
                }
                if (j >= (int)Math.sqrt(i)){
                    System.out.println(i);
                }
            }
        }
    }
    public static void isSushu(int num){
        if(num < 4) {
            System.out.println(num + "是素数");
            return;
        }
        for (int i = 2; i < Math.sqrt(num); i++) {
            if (num % i == 0){
                System.out.println(num + "不是素数");
                break;
            }
            if (i >= (int)Math.sqrt(num)){
                System.out.println(num + "是素数");
            }
        }
    }
    public static void ageStage(int age){
        if (age <= 18){
            System.out.println("少年");
        }else if (age > 18 && age <= 28){
            System.out.println("青年");
        }else if (age > 56){
            System.out.println("老年");
        }else {
            System.out.println("中年");
        }
    }
    public static void isTrue(int guessNum,int random){
        if (guessNum == random){
            System.out.println("回答正确，游戏结束");
            return;
        }else if (guessNum >random){
            System.out.println("输入的数字大于随机数，请从新输入");
            Scanner scanner = new Scanner(System.in);
            int input = scanner.nextInt();
            isTrue(input,random);
        }else {
            System.out.println("输入的数字小于随机数，请从新输入");
            Scanner scanner = new Scanner(System.in);
            int input = scanner.nextInt();
            isTrue(input,random);
        }
    }
    public static void printNum(int num){
        //终止条件，无需借用其他函数就可以知道救赎条件
        if (num < 10){

            System.out.println(num+" ");
            return;
        }
        //num> 10
//        此时我只可能知道他的个数
        printNum(num/10);


    }
    public static int factorNum(int num) {
        int sum = 0;
        //递归终止条件
        if (num == 1) {
            return 1;
        }
        return num * factorNum(num - 1);
    }
    public static int max1(int num1,int num2){
        return num1 > num2 ? num1 : num2;
    }
    public static int max2(int num1,int num2,int num3){
        return max1(max1(num1,num2),num3);
    }
    public static int max(int num1,int num2){
        return num1 > num2 ? num1 : num2;
    }
    public static double max(double num1,double num2){
        return num1 > num2 ? num1 : num2;
    }
    public static double max(int num1, int num2, double num3){
        return max(max(num1, num2),num3);
    }
    public static int sum(int num1,int num2){
        return num1+num2;
    }
    public static double sum(double num1,double num2,double num3){
        return num1 + num2 + num3;
    }
    public static int jump(int num){
        if (num == 1){
            return 1;
        }
        if (num == 2){
            return 2;
        }
        return jump(num -1) + jump(num-2);
    }
    public static int Hanota(int num,char A ,char B,char C,int count){
        count++;
        if (num == 1){
            System.out.println("把第"+num+"个盘子从"+A+"放到"+C+"盘");
            return count;
        }
        //如果有两个以上的盘子，则把上面n-1个盘子看作一个整体，将他从第一个柱子移到第二个柱子
        int hanota = Hanota(num - 1, A, C, B, count);
        System.out.println("第" + num + "个盘子从" + A + "移动到" + C);
        return Hanota(num - 1, B, A, C,hanota);
    }
    public static int febonqie(int num){
        if (num == 1 || num == 2){
            return 1;
        }
        return febonqie(num-1)+febonqie(num-2);
    }
    public static int eachNumSum(int num){
        if (num < 10){
            return num;
        }
        return num%10+eachNumSum(num/10);
    }
    public static void printEach(int num){
        //递归终止，如果num《10，则说明就是最后以为，输出
        if (num < 10){
            System.out.print(num+" ");
            return;
        }else {
            //否则我只知道当前数的最后一位，并且这一位要最后打印，其他未不知道，交给一个方法去完成。
            printEach(num/10);
        }
        System.out.print(num%10+" ");
    }
    public static int sum(int num){
        if (num == 1){
            return num;
        }
        //我只知道当前的数，其他数不知道,将其他的数通过一个方法求出
        return num + sum(num - 1);
    }
    public static int jieChen(int num){
        if (num == 2){
            return num;
        }
        return num * jieChen(num-1);
    }
    public static void transform(int[] arr){
        for(int i : arr){
            System.out.print(i+" ");
        }
    }
    public static void fullArr(){
        int[] arr = new int[100];
        for (int i = 1; i <= 100; i++) {
            if (i % 10 == 0){
                arr[i-1] = 10;
            }else {
                arr[i-1] = i % 10;
            }
        }
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]+" ");
            if ((i+1) % 10 == 0){
                System.out.println();
            }
        }
    }
    public static int[] copyOf(int[] arr){
        int len = arr.length;
        int[] nums = new int[len];
        for (int i = 0; i < len; i++) {
            nums[i] = arr[i];
        }
        return nums;
    }


}
